import 'package:xvideos/hj_model/acg/comic_chapters_model.dart';
import 'package:xvideos/hj_model/acg/search_index_model.dart';
import 'package:xvideos/hj_model/cartoon_media_info.dart';
import 'package:xvideos/hj_model/comment/user_comment_res.dart';
import 'package:xvideos/hj_model/home/collection_resp.dart';
import 'package:xvideos/hj_model/message/search_user_obj.dart';
import 'package:xvideos/hj_model/mine/promotion_record.dart';
import 'package:xvideos/hj_model/video_model.dart';
import 'package:xvideos/hj_page/mine_business/ai/mode/AiChangeFaceVideoMod.dart';
import 'package:xvideos/hj_page/mine_business/ai/mode/ai_record_entity.dart';

class ListBaseModel<T> {
  bool? hasNext;
  List<T>? list;
  int? total;

  ListBaseModel.fromJson(Map<String, dynamic> map) {
    total = map['total'];
    hasNext = map['hasNext'] ?? false;
    final type = T.toString();
    if (type == 'Promotion') {
      list = ((map['list'] as List?)?.map((e) => Promotion.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'CartoonMediaInfo') {
      list = ((map['list'] as List?)?.map((e) => CartoonMediaInfo.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'ComicChapterInfo') {
      list = ((map['list'] as List?)?.map((e) => ComicChapterInfo.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'UserCommentItem') {
      list = ((map['list'] as List?)?.map((e) => UserCommentItem.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'CollectionModel') {
      list = ((map['list'] as List?)?.map((e) => CollectionModel.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'AiRecordModel') {
      list = ((map['list'] as List?)?.map((e) => AiRecordModel.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'HotBloggerEntity') {
      list = ((map['list'] as List?)?.map((e) => HotBloggerEntity.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'AiChangeFaceVideoMod') {
      list = ((map['list'] as List?)?.map((e) => AiChangeFaceVideoMod.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'HotTag') {
      list = ((map['list'] as List?)?.map((e) => HotTag.fromJson(e)).toList() ?? <T>[]) as List<T>;
    } else if (type == 'VideoModel') {
      list = ((map['list'] as List?)?.map((e) => VideoModel.fromJson(e)).toList() ?? <T>[]) as List<T>;
    }
  }
}
